package com.sservice.commonBusiness.controller.admin;

import com.sservice.commonBusiness.e.BusinessApply;
import com.sservice.commonBusiness.service.BusinessApplyService;
import com.sservice.base.entity.dto.BaseResult;
import com.sservice.base.entity.dto.ListResult;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Created by byte_su@163.com on 2018/02/26.
 */
@Controller
@RequestMapping("/admin/businessApply/")
public class AdminBusinessApplyController {

    @Autowired
    BusinessApplyService businessApplyService;

    @RequestMapping(value = "add", method = RequestMethod.POST)
    @ResponseBody
    public BaseResult add(BusinessApply businessApply) {
        return new BaseResult(true, String.valueOf(businessApplyService.insertSelective(businessApply)), 200);
    }

    @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
    @ResponseBody
    public BaseResult delete(@RequestParam Integer id) {
        return new BaseResult(true, String.valueOf(businessApplyService.deleteByPrimaryKey(id)), 200);
    }

    @RequestMapping(value = "update", method = RequestMethod.POST)
    @ResponseBody
    public BaseResult update(BusinessApply businessApply) {
        return new BaseResult(true, String.valueOf(businessApplyService.updateByPrimaryKeySelective(businessApply)), 200);
    }

    @RequestMapping("detail/{id}")
    @ResponseBody
    public BaseResult detail(@RequestParam Integer id) {
        BusinessApply businessApply = businessApplyService.selectByPrimaryKey(id);
        return new BaseResult(true, businessApply);
    }

    @RequestMapping("query")
    @ResponseBody
    public ListResult list(BusinessApply record) {
        return businessApplyService.page(record);
    }
}
